home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Moscow ML 1.42 / lib / Mosmlcgi.sig < prev    next >
Encoding:
Text File  |  1997-08-18  |  5.8 KB  |  172 lines  |  [TEXT/Moml]

  1. (* Mosmlcgi -- Support for writing CGI scripts in Moscow ML 
  2.  
  3.  (c) Jonas Barklund, Computing Science Dept., Uppsala University, 1996.
  4.      Documentation and support for file upload added by Peter Sestoft.
  5. *)
  6.  
  7. (* 1. Accessing the fields or parameters of a CGI call *)
  8.  
  9. val cgi_fieldnames : string list
  10. val cgi_field_strings : string -> string list;
  11. val cgi_field_string  : string -> string option;
  12. val cgi_field_integer : string * int -> int;
  13.  
  14. (* 2. Accessing parts in multipart/form-data; form-based file upload *)
  15.  
  16. val cgi_partnames : string list
  17.  
  18. type part
  19. val cgi_part  : string -> part option
  20. val cgi_parts : string -> part list
  21.  
  22. val part_fieldnames    : part -> string list
  23. val part_type          : part -> string option
  24. val part_data          : part -> string
  25. val part_field_strings : part -> string -> string list
  26. val part_field_string  : part -> string -> string option
  27. val part_field_integer : part -> string * int -> int
  28.  
  29. (* 3. Administrative information *)
  30.  
  31. val cgi_server_software   : string option;
  32. val cgi_server_name       : string option;
  33. val cgi_gateway_interface : string option;
  34. val cgi_server_protocol   : string option;
  35. val cgi_server_port       : string option;
  36. val cgi_request_method    : string option;
  37. val cgi_http_accept       : string option;
  38. val cgi_http_user_agent   : string option;
  39. val cgi_http_referer      : string option;
  40. val cgi_path_info         : string option;
  41. val cgi_path_translated   : string option;
  42. val cgi_script_name       : string option;
  43. val cgi_query_string      : string option;
  44. val cgi_remote_host       : string option;
  45. val cgi_remote_addr       : string option;
  46. val cgi_remote_user       : string option;
  47. val cgi_remote_ident      : string option;
  48. val cgi_auth_type         : string option;
  49. val cgi_content_type      : string option;
  50. val cgi_content_length    : string option;
  51. val cgi_annotation_server : string option;
  52.  
  53. (* The Mosmlcgi library is for writing CGI programs in Moscow ML.  A
  54.    CGI program may be installed on a WWW server and is invoked in
  55.    response to HTTP requests sent to the server from a web browser,
  56.    typically from an HTML FORM element.
  57.  
  58.  
  59.    1. Obtaining field values sent from an ordinary HTML form
  60.    ---------------------------------------------------------
  61.  
  62.    [cgi_fieldnames] is a list of the names of fields present in the
  63.    CGI call message.  If field name fnm is in cgi_fieldnames, then
  64.    cgi_field_string fnm <> NONE.
  65.  
  66.    [cgi_field_strings fnm] is a (possibly empty) list of the strings
  67.    bound to field fnm.
  68.  
  69.    [cgi_field_string fnm] returns SOME(s) where s is a string bound to
  70.    field name fnm, if any; otherwise NONE.  Equivalent to 
  71.     case cgi_field_strings fnm of 
  72.              []     => NONE 
  73.            | s :: _ => SOME s
  74.  
  75.    [cgi_field_integer (fnm, deflt)] attempts to parse an integer from
  76.    field fnm.  Returns i if cgi_field_string(fnm) = SOME(s) and an
  77.    integer i can be parsed from a prefix of s; otherwise returns deflt.
  78.  
  79.  
  80.    2. Obtaining field values sent with ENCTYPE="multipart/form-data"  
  81.    -----------------------------------------------------------------
  82.  
  83.    [cgi_partnames] is a list of the names of the parts of the
  84.    multipart/form-data message.
  85.  
  86.    The type part is the abstract type of parts of a message.  Each part
  87.    may have several fields.  In this implementation, the field of a
  88.    part cannot be a another part itself.
  89.  
  90.    [cgi_parts pnm] is a (possibly empty) list of the parts called pnm.
  91.  
  92.    [cgi_part pnm] is SOME(prt) where prt is a part called pnm, if any;
  93.    otherwise NONE.  Equivalent to
  94.     case cgi_parts pnm of 
  95.              []       => NONE 
  96.            | prt :: _ => SOME prt
  97.  
  98.    [part_fieldnames prt] is the list of field names in part pnm.
  99.  
  100.    [part_type prt] is SOME(typ) if the part prt contains a specification
  101.    `Context-Type: typ'; otherwise NONE.
  102.  
  103.    [part_data prt] is the data contain in part prt; for instance, the
  104.    contents of a file uploaded via form-based file upload.
  105.  
  106.    [part_field_strings prt fnm] is a (possibly empty) list of the
  107.    strings bound to field fnm in part prt.
  108.  
  109.    [part_field_string prt fnm] returns SOME(s) where s is a string
  110.    bound to field name fnm in part prt, if any; otherwise NONE.
  111.    Equivalent to 
  112.     case part_field_strings prt fnm of 
  113.          []     => NONE 
  114.        | s :: _ => SOME s
  115.  
  116.    [part_field_integer prt (fnm, deflt)] attempts to parse an integer
  117.    from field fnm of part prt.  Returns i if part_field_string prt fnm
  118.    = SOME(s) and an integer i can be parsed from a prefix of s;
  119.    otherwise returns deflt.
  120.  
  121.  
  122.    3. Administrative and server information
  123.    ----------------------------------------
  124.  
  125.    Each of the following variables has the value SOME(s) if the
  126.    corresponding CGI environment variable is bound to string s;
  127.    otherwise NONE:
  128.  
  129.    [cgi_server_software] is the value of SERVER_SOFTWARE
  130.  
  131.    [cgi_server_name] is the value of SERVER_NAME
  132.  
  133.    [cgi_gateway_interface] is the value of GATEWAY_INTERFACE
  134.  
  135.    [cgi_server_protocol] is the value of SERVER_PROTOCOL
  136.  
  137.    [cgi_server_port] is the value of SERVER_PORT
  138.  
  139.    [cgi_request_method] is the value of REQUEST_METHOD
  140.  
  141.    [cgi_http_accept] is the value of HTTP_ACCEPT
  142.  
  143.    [cgi_http_user_agent] is the value of HTTP_USER_AGENT
  144.  
  145.    [cgi_http_referer] is the value of HTTP_REFERER
  146.  
  147.    [cgi_path_info] is the value of PATH_INFO
  148.  
  149.    [cgi_path_translated] is the value of PATH_TRANSLATED
  150.  
  151.    [cgi_script_name] is the value of SCRIPT_NAME
  152.  
  153.    [cgi_query_string] is the value of QUERY_STRING
  154.  
  155.    [cgi_remote_host] is the value of REMOTE_HOST
  156.  
  157.    [cgi_remote_addr] is the value of REMOTE_ADDR
  158.  
  159.    [cgi_remote_user] is the value of REMOTE_USER
  160.  
  161.    [cgi_remote_ident] is the value of REMOTE_IDENT
  162.  
  163.    [cgi_auth_type] is the value of AUTH_TYPE
  164.  
  165.    [cgi_content_type] is the value of CONTENT_TYPE
  166.  
  167.    [cgi_content_length] is the value of CONTENT_LENGTH, that is, the
  168.    length of the data transmitted in the CGI call.
  169.  
  170.    [cgi_annotation_server] is the value of ANNOTATION_SERVER
  171. *)
  172.